package com.boarsoft.rpc.bean;

import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class RpcRegistry implements Serializable {
	private static final long serialVersionUID = 1262809103083863664L;

	protected Date version;
	protected String key;
	/** k: refereceId */
	protected Map<String, RpcReferenceConfig> referenceMap = new HashMap<String, RpcReferenceConfig>();
	protected Map<String, RpcServiceConfig> serviceMap = new HashMap<String, RpcServiceConfig>();

	public RpcRegistry(String addr) {
		this.key = addr;
	}

	public RpcRegistry() {
	}

	public int getServiceMethodId(String serviceKey, Method method) {
		RpcServiceConfig sc = this.serviceMap.get(serviceKey);
		RpcMethodConfig mc = sc.getMethodConfig(method);
		return mc.getRelativeId();
	}

	public Map<String, RpcReferenceConfig> getReferenceMap() {
		return this.referenceMap;
	}

	public void setReferenceMap(Map<String, RpcReferenceConfig> referenceMap) {
		this.referenceMap = referenceMap;
	}

	public Map<String, RpcServiceConfig> getServiceMap() {
		return this.serviceMap;
	}

	public void setServiceMap(Map<String, RpcServiceConfig> serviceMap) {
		this.serviceMap = serviceMap;
	}

	public Date getVersion() {
		return this.version;
	}

	public void setVersion(Date version) {
		this.version = version;
	}

	public String getKey() {
		return this.key;
	}

	public void setKey(String key) {
		this.key = key;
	}
}
